<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ECSHOP 管理中心 - 地区列表 </title>
<base href="__STATIC__/Admin/">
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<style>
  .panel-icloud .panel-right iframe {
    height: 300px;
    margin-top: 15px;
  }
  .panel-hint{
    top: 3%;
  }
  ul li{
      float: left;
      list-style: none;
      margin-left: 100px;
      margin-top: 20px;
      margin-right: 100px;
  }
</style>

</head>
<body>

<!--遮罩-->
<div class="mask-black" id="CMask"></div>
<!--遮罩-->
<h1>
  {if condition="($parent['parent_id'] == 0)"}
       <span class="action-span"><a href="{:url('Admin/System/area_list')}?id={$parent['parent_id']}">返回上一级</a></span>     
  {else/}
      <span class="action-span"><a href="{:url('Admin/System/area_list_type')}?id={$parent['parent_id']}">返回上一级</a></span>
  {/if}
  	

<span class="action-span1"><a href="index.php?act=main">ECSHOP 管理中心</a> </span><span id="search_id" class="action-span1"> &nbsp;&nbsp;&nbsp;&nbsp; 地区列表 </span>
<div style="clear:both"></div>
</h1><div class="form-div">
<!-- <form method="post" action="{:url('Admin/System/area_addd')}" name="theForm"> -->
  {if condition="($parent['region_type'] == 0)"}
            新增二级地区
            <input type="text" name="region_name" maxlength="150" size="40" class="rname" />
            <input type="hidden" name="region_type" value="1" class="type" />
            <input type="hidden" name="parent_id" value="{$parent['region_id']}" class="pid" />           
  {elseif condition="($parent['region_type'] == 1)"/}
            新增三级地区:
            <input type="text" name="region_name" maxlength="150" size="40" class="rname" />
            <input type="hidden" name="region_type" value="2" class="type" />
            <input type="hidden" name="parent_id" value="{$parent['region_id']}" class="pid" />
  {elseif condition="($parent['region_type'] == 2)"/}
            新增四级地区:
            <input type="text" name="region_name" maxlength="150" size="40" class="rname" />
            <input type="hidden" name="region_type" value="3" class="type" />
            <input type="hidden" name="parent_id" value="{$parent['region_id']}" class="pid" />
  {/if}
  <input type="submit" value=" 确定 " class="button" />
<!-- </form> -->
</div>

<!-- start category list -->
<div class="list-div">
<table cellspacing='1' cellpadding='3' id='listTable'>
  <tr>
    <th>
        [ {$parent.region_name} ] 
        {if condition="($parent['region_type'] == 0)"}
            二级地区
        {elseif condition="($parent['region_type'] == 1)"/}
            三级地区:
        {elseif condition="($parent['region_type'] == 2)"/}
            四级地区:
        {/if}
    </th>
  </tr>
</table>
</div>
<div class="list-div" id="listDiv">

<table cellspacing='1' cellpadding='3' id='listTable'>
  {foreach $list as $v}
    <ul id="word">
        <li class="first-cell" align="center">
         <span>{$v.region_name}</span>
         <span class="link-span">
          {if condition="($parent['region_type'] == 0)"}
              <a href="{:url('Admin/System/area_list_type')}?id={$v.region_id}" title="管理">
             管理</a>&nbsp;&nbsp;
          {elseif condition="($parent['region_type'] == 1)"/}
              <a href="{:url('Admin/System/area_list_type')}?id={$v.region_id}" title="管理">
             管理</a>&nbsp;&nbsp;
          {/if}
                <a href="javascript:;" title="删除" class="sc" id="{$v.region_id}">删除</a>
         </span>
        </li>
    </ul>
  {/foreach}
      <tr id="word">
            
      </tr>
</table>

</div>

<div id="footer">版权所有 &copy; 2005-2018 上海商派软件有限公司，并保留所有权利。</div>
</body>
<script src="jquery.js"></script>
<script>
      $(".button").on('click',function(){
          var rname = $(".rname").val();
          if(rname ==''){
              alert('不能为空');
              return false;
          }
          var type = $(".type").val();
          var pid = $(".pid").val();
          $.ajax({
              url:"{:url('Admin/System/area_add')}",
              type:"post",
              data:{parent_id:pid,region_type:type,region_name:rname},
              dataType:'json',
              success:function(e){
                if(e.code==1){
                    $('#word').append('<li class="first-cell" align="left">'+e.data+'</li>');
                    history.go(0)
                }
              }
          });
      });

      $(".sc").on('click',function(){
          var id = $(this).attr('id');
          $.ajax({
              url:"{:url('Admin/System/area_del')}",
              type:"get",
              data:{id:id},
              dataType:'json',
              success:function(e){
                if(e.code==1){
                    alert(e.msg)
                    history.go(0);
                }else if(e.code==0){
                    alert(e.msg)
                    history.go(0);
                }
              }
          });
      });
</script>
</html>